﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class UsesElement : SyntaxTreeElement
    {
        private List<UseElement> uses;

        public List<UseElement> Uses { get { return uses; } set { uses = value; } }

        public UsesElement(TokenInfo StartInfo, List<UseElement> Uses, List<TokenInfo> Comments)
            : base(StartInfo, Comments)
        {
            uses = Uses;
        }

        public override string ToString()
        {
            if ((uses != null) && (uses.Count > 0))
                return string.Format("uses\r\n{0};{1}", Tabulate(uses.Join(",\r\n")), CommentsString());
            else return string.Empty;
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            if (uses != null)
                foreach (UseElement use in uses)
                    yield return use;
        }
    }
}
